/**
 * DO NOT REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 *
 * Contributor(s):
 *
 * The Original Software is SimpleDBM (www.simpledbm.org). 
 * The Initial Developer of the Original Software is Dibyendu Majumdar. 
 *
 * Portions Copyright 2005-2014 Dibyendu Majumdar. All Rights Reserved.
 *
 * The contents of this file are subject to the terms of the 
 * Apache License Version 2 (the "APL"). You may not use this 
 * file except in compliance with the License. A copy of the
 * APL may be obtained from:
 * http://www.apache.org/licenses/LICENSE-2.0 
 *
 * Alternatively, the contents of this file may be used under the terms of
 * either the GNU General Public License Version 2 or later (the "GPL"), or
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 * in which case the provisions of the GPL or the LGPL are applicable instead
 * of those above. If you wish to allow use of your version of this file only
 * under the terms of either the GPL or the LGPL, and not to allow others to
 * use your version of this file under the terms of the APL, indicate your
 * decision by deleting the provisions above and replace them with the notice
 * and other provisions required by the GPL or the LGPL. If you do not delete
 * the provisions above, a recipient may use your version of this file under
 * the terms of any one of the APL, the GPL or the LGPL.
 *
 * Copies of GPL and LGPL may be obtained from:
 * http://www.gnu.org/licenses/license-list.html
 */
package org.simpledbm.common.util;

import java.nio.charset.Charset;

import org.simpledbm.common.api.exception.SimpleDBMException;
import org.simpledbm.common.util.mcat.Message;
import org.simpledbm.common.util.mcat.MessageInstance;
import org.simpledbm.common.util.mcat.MessageType;

/**
 * Some utilities for Strings
 * 
 * @author dibyendumajumdar
 * @since 29 Jan 2011
 */
public class StringUtils {

    static Message m_EU0001 = new Message('P', 'U', MessageType.ERROR, 1,
    	"Unexpected error occurred when retrieving bytes from {0}");

	public static byte[] getUTF8Bytes(String s) {
		try {
			return s.getBytes(Charset.forName("UTF-8"));
		}
		catch (Exception e) {
			throw new SimpleDBMException(new MessageInstance(m_EU0001));
		}
	}
	
}
